
AddCSLuaFile( "shared.lua" )

SWEP.Category 		= "HL2 Beta Sweps"
SWEP.PrintName		= "Alyx Gun"	
SWEP.Author		= "Valve"
SWEP.Contact		= "n/a"
SWEP.Purpose		= "Kill."
SWEP.Instructions	= "Primary=Shoot Secondary=Smg Mode"

SWEP.ViewModelFOV	= 55
SWEP.ViewModelFlip	= false
SWEP.ViewModel		= "models/weapons/v_alyx_gun.mdl"
SWEP.WorldModel		= "models/weapons/w_alyx_gun.mdl"
SWEP.AnimPrefix		= "pistol"
SWEP.HoldType		= "pistol"

SWEP.Spawnable			= true
SWEP.AdminSpawnable		= false

SWEP.Primary.ClipSize		= 30			// Size of a clip
SWEP.Primary.DefaultClip	= 90			// Default number of bullets in a clip
SWEP.Primary.Automatic		= true			// Automatic/Semi Auto
SWEP.Primary.Delay		= 0.3
SWEP.Primary.Ammo		= "AlyxGun"

SWEP.Secondary.ClipSize		= -1			// Size of a clip
SWEP.Secondary.DefaultClip	= -1			// Default number of bullets in a clip
SWEP.Secondary.Automatic	= false			// Automatic/Semi Auto
SWEP.Secondary.Ammo		= "none"

Zoom = 0

/*---------------------------------------------------------
	Initialize
---------------------------------------------------------*/
function SWEP:Initialize()

end

function SWEP:Deploy()
	self.Weapon:SendWeaponAnim(ACT_VM_DRAW)
      return true
end
/*---------------------------------------------------------
	Holster
---------------------------------------------------------*/
function SWEP:Holster()
	self.Owner:SetFOV( 0, 0 )
	Zoom = 0

	return true
end



/*---------------------------------------------------------
	Reload
---------------------------------------------------------*/
function SWEP:Reload( )
	if(Zoom == 0) then
		if(SERVER) then
			self.Weapon:DefaultReload( ACT_VM_RELOAD )
		end
		self:EmitSound("weapons/pistol/pistol_reload1.wav")
		Zoom = 0
	else
		if(SERVER) then
			self.Weapon:DefaultReload( ACT_VM_FIDGET )
		end
		self:EmitSound("weapons/pistol/pistol_reload1.wav")
		Zoom = 1
	end
end

/*---------------------------------------------------------
   Think
---------------------------------------------------------*/
function SWEP:Think()
end


/*---------------------------------------------------------
	PrimaryAttack
---------------------------------------------------------*/
function SWEP:PrimaryAttack()

	// Make sure we can shoot first
	if ( !self:CanPrimaryAttack() ) then return end

	//Pistol Mode
	if (Zoom == 0 || self:Clip1() < 2 ) then
		// Shoot 1 bullet, 25 damage, 0.07 aimcone
		self:ShootBullet( 10, 1, 0.015 )
		// Delay Attack
		self.Weapon:SetNextPrimaryFire( CurTime() + 0.125 )
		// Play shoot sound
		self:EmitSound( Sound("weapons/alyx_gun/alyx_gun_fire4.wav") )
		// Remove 1 bullet from our clip
		self:TakePrimaryAmmo( 1 )
                // Teh Fire Mode
                self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
	else
		// Smg Mode
		self.Weapon:SetNextPrimaryFire( CurTime() + 0.09 )
		// Shoot 1 bullet, 5 damage, 0.1 aimcone
		self:ShootBullet( 15, 1, 0.005 )
		// Play shoot sound
		self:EmitSound( Sound("weapons/alyx_gun/alyx_gun_fire6.wav") )
		// Remove 1 bullet from our clip
		self:TakePrimaryAmmo( 1 )
                // Teh Fire Mode
                self.Weapon:SendWeaponAnim( ACT_VM_SECONDARYATTACK )
	end
	
end

/*---------------------------------------------------------
	SecondaryAttack
---------------------------------------------------------*/
function SWEP:SecondaryAttack()

	if(Zoom == 0) then
		if(SERVER) then
			self.Weapon:SendWeaponAnim( ACT_VM_PULLBACK_HIGH )
		end
		self:EmitSound("weapons/alyxgun/alyxgun_switch_single.wav")
		Zoom = 1
	else
		if(SERVER) then
			self.Weapon:SendWeaponAnim( ACT_VM_PULLBACK_LOW )
		end
		self:EmitSound("weapons/alyxgun/alyxgun_switch_burst.wav")
		Zoom = 0
	end
end

// Add to Weapon List
list.Set("NPCWeapons","alyx_gun","Alyxgun");

// These tell the NPC how to use the weapon
AccessorFunc( SWEP, "fNPCMinBurst", 	2 )
AccessorFunc( SWEP, "fNPCMaxBurst", 	5 )
AccessorFunc( SWEP, "fNPCFireRate", 	0.08 )
AccessorFunc( SWEP, "fNPCMinRestTime", 	1 )
AccessorFunc( SWEP, "fNPCMaxRestTime", 	2 )

/*---------------------------------------------------------
	Capabilities
---------------------------------------------------------*/
function SWEP:GetCapabilities()

	return CAP_WEAPON_RANGE_ATTACK1 | CAP_INNATE_RANGE_ATTACK1

end